#include<bits/stdc++.h>
#define LL int
#define SZ(x) ((LL)(x.size()))
#define all(x) (x).begin(),(x).end()
using namespace std;
inline LL read(){
  LL q=0,w=1;char ch=getchar();
  while(ch>'9' || ch<'0'){if(ch=='-')w=-1;ch=getchar();}
  while(ch>='0'&&ch<='9'){q=q*10+(ch-'0');ch=getchar();}
  return q*w;
}
void write(LL x){
  if(x<0){putchar('-');x=(-x);}
  if(x>9)write(x/10);
  putchar('0'+x%10);
}
inline void writeln(LL x){write(x);puts("");}
inline void writecs(LL x){write(x);putchar(' ');}

inline void EXIT(){puts("-1");}

template<LL N>struct us{
  LL fa[N];
  inline void init(LL n){
    for(LL i=1;i<=n;i++)fa[i]=i;
    return ;
  }
  LL find(LL x){return (fa[x]==x?x:(fa[x]=find(fa[x])));}
  inline LL merge(LL x,LL y){
    //    cout<<"> merge: x = "<<x<<" y = "<<y<<endl;
    x=find(x);y=find(y);if(x<y)swap(x,y);
    if(x==y)return 0;
    fa[x]=y;return 1;
  }
};

#define PL pair<LL,LL>
#define mp make_pair
#define fir first
#define sec second

const int N = 1000000+95 , L = 21 ;
LL n,m,a[N],_a[N],b[N<<1],lg[N];us<(N<<1)>dat[L];vector<PL>E[N];

vector<LL>F[N];LL dfn[N],low[N],tim;bool vis[N];LL st[N],top;
void tarjan(LL x){
  dfn[x]=low[x]=++tim;vis[x]=1;st[++top]=x;
  for(auto y:F[x]){
    if(!dfn[y]){tarjan(y);low[x]=min(low[x],low[y]);}
    else if(vis[y])low[x]=min(low[x],dfn[y]);
  }
  if(dfn[x]==low[x]){
    LL y=0;do{y=st[top];top--;vis[y]=0;dat[0].merge(x,y);}while(y!=x);
  }
  return ;
}
LL cnt[N<<1],seq[N<<1];
void solve(){
  n=read();m=(n<<1);LL FL=1;
  for(LL i=1;i<=n+1;i++){_a[i]=0;E[i].clear();F[i].clear();}
  for(LL i=1;i<=n;i++){
    a[i]=read();a[i]++;
    if(_a[a[i]]!=0){FL=0;break;}
    _a[a[i]]=i;
  }
  for(LL i=1;i<m;i++)b[i]=read();
  if(!FL){EXIT();return ;}

  lg[0]=-1;for(LL i=1;i<=n;i++)lg[i]=lg[i>>1]+1;

  for(LL k=0;k<=lg[n];k++)dat[k].init(m);
  auto change=[&](LL l,LL r){
		//		cout<<"> l = "<<l<<" r = "<<r<<endl;
		if(l<1||r>n)return false;
		LL k=lg[r-l+1];
		dat[k].merge(l,n+r-(1<<k)+1);
		return true;
	      };
  for(LL i=1;i<m;i++){
    if((i&1)){//在一个字符上
      LL pos=((i+1)>>1);
      if(!(b[i]&1)){EXIT();return ;}
      LL r=((b[i]-1)>>1);
      if(!change(pos-r,pos+r)){EXIT();return ;}
    }
    else {//在两个字符之间
      LL pos=(i>>1);
      if(b[i]&1){EXIT();return ;}
      LL r=(b[i]>>1);
      if(r){if(!change(pos-r+1,pos+r)){EXIT();return ;}}
    }
  }

  for(LL k=lg[n];k>0;k--){
    //    cout<<"> k = "<<k<<" : "<<endl;
    for(LL i=1;i<=m;i++)cnt[i]=0;
    for(LL i=1;i<=n-(1<<k)+1;i++){cnt[dat[k].find(i)]++;cnt[dat[k].find(n+i)]++;}
    for(LL i=1;i<=m;i++)cnt[i]+=cnt[i-1];
    for(LL i=1;i<=n-(1<<k)+1;i++){seq[cnt[dat[k].find(i)]--]=i;seq[cnt[dat[k].find(n+i)]--]=n+i;}
    LL lim=((n-(1<<k)+1)<<1);
    //    for(LL i=1;i<=lim;i++)cout<<seq[i]<<" "<<dat[k].find(seq[i])<<endl;
    for(LL l=1,r=0;l<=lim;l=r+1){
      r=l;while(r+1<=lim&&dat[k].find(seq[l])==dat[k].find(seq[r+1]))r++;
      LL u=seq[l];
      for(LL i=l+1;i<=r;i++){
	LL v=seq[i];
	//	cout<<" u = "<<u<<" v = "<<v<<endl;
	if(u<=n&&v<=n){dat[k-1].merge(u,v);dat[k-1].merge(u+(1<<(k-1)),v+(1<<(k-1)));}
	if(u<=n&& v>n){dat[k-1].merge(u+(1<<(k-1)),v);dat[k-1].merge(u,v+(1<<(k-1)));}
	if(u>n &&v<=n){dat[k-1].merge(u+(1<<(k-1)),v);dat[k-1].merge(u,v+(1<<(k-1)));}
	if(u>n && v>n){dat[k-1].merge(u,v);dat[k-1].merge(u+(1<<(k-1)),v+(1<<(k-1)));}
      }
    }
  }
  for(LL i=1;i<=n;i++)dat[0].merge(i,n+i);
  
  for(LL i=1;i<n;i++){
    LL w=((_a[a[i]+1]>_a[a[i+1]+1])?(1):(0));
    if(!w)F[dat[0].find(a[i])].push_back(dat[0].find(a[i+1]));
  }
  tim=0;
  for(LL x=1;x<=n;x++)
    if(dat[0].find(x)==x)dfn[x]=low[x]=0;
  for(LL x=1;x<=n;x++)
    if(dat[0].find(x)==x&&!dfn[x])tarjan(x);
  
  //  for(LL i=1;i<=n;i++)cout<<" i = "<<i<<" dat[0].find(i) = "<<dat[0].find(i)<<endl;

  auto add_e=[&](LL u,LL v,LL w){
	       if(w==0&&u==v)return ;
	       //	       cout<<"> add_e: u = "<<u<<" v = "<<v<<" w = "<<w<<endl;
	       E[u].push_back(mp(v,w));return ;};
  for(LL i=1;i<m;i++){
    //    cout<<"> i = "<<i<<endl;
    auto make=[&](LL u,LL v){
		//		cout<<"> make: u = "<<u<<" v = "<<v<<endl;
		if(_a[u]<_a[v])add_e(dat[0].find(u),dat[0].find(v),1);
		else add_e(dat[0].find(v),dat[0].find(u),1);
		return ;
	      };
    if((i&1)){
      LL pos=((i+1)>>1);
      LL r=((b[i]-1)>>1);
      LL u=pos-r-1,v=pos+r+1;
      if(u>=1&&v<=n)make(u,v);
    }
    else {
      LL pos=(i>>1);
      LL r=(b[i]>>1);
      LL u=pos-r,v=pos+r+1;
      if(u>=1&&v<=n)make(u,v);
    }
  }
  for(LL i=1;i<n;i++){
    LL w=((_a[a[i]+1]>_a[a[i+1]+1])?(1):(0));
    //    cout<<"--- a[i] = "<<a[i]<<" a[i+1] = "<<a[i+1]<<" w = "<<w<<endl;
    add_e(dat[0].find(a[i]),dat[0].find(a[i+1]),w);
  }
  vector<LL>deg(n+2,0);
  for(LL x=1;x<=n;x++)
    if(dat[0].find(x)==x)
      for(auto u:E[x]){LL y=u.fir;deg[y]++;}
  queue<LL>q;vector<LL>dp(n+2,0);LL ans=0;
  for(LL x=1;x<=n;x++)
    if(dat[0].find(x)==x&&!deg[x]){dp[x]=1;q.push(x);}
  while(!q.empty()){
    LL x=q.front();q.pop();ans=max(ans,dp[x]);
    //    cout<<" x = "<<x<<" dp[x] = "<<dp[x]<<endl;
    for(auto u:E[x]){
      LL y=u.fir,w=u.sec;
      dp[y]=max(dp[y],dp[x]+w);
      //      cout<<"-> y = "<<y<<" deg[y] = "<<deg[y]<<endl;
      deg[y]--;if(!deg[y])q.push(y);
    }
  }
  //  for(LL x=1;x<=n;x++)cout<<" x = "<<x<<" deg[x] = "<<deg[x]<<endl;
  if(ans>26){EXIT();return ;}
  for(LL x=1;x<=n;x++)
    if(dat[0].find(x)==x&&deg[x]>0){EXIT();return ;}
  //  cout<<"> a : ";for(LL i=1;i<=n;i++)cout<<a[i]<<" ";cout<<endl;
  //  cout<<"> b : ";for(LL i=1;i<m;i++)cout<<b[i]<<" ";cout<<endl;
  //  string str="";
  for(LL i=1;i<=n;i++){
    putchar('a'+dp[dat[0].find(i)]-1);
    //    str+=('a'+dp[dat[0].find(i)]-1);
  }
  puts("");
  /*  vector<LL>ord(n);for(LL i=0;i<n;i++)ord[i]=i;
  auto suf=[&](LL x){
	     string s="";
	     for(LL i=x;i<n;i++)s+=str[i];
	     return s;
	   };
  sort(all(ord),[&](LL x,LL y){return suf(x)<suf(y);});
  cout<<" ord : ";
  for(LL i=0;i<SZ(ord);i++)cout<<ord[i]<<" ";cout<<endl;*/
  return ;
}
int main(){
  freopen("string.in","r",stdin);
  freopen("string.out","w",stdout);
  LL TC=read();
  while(TC--)solve();
  return 0;
}
/*
my test data:
input:
1
10
4 7 9 3 0 5 1 6 8 2 
1 0 1 0 1 0 1 0 1 0 1 0 1 0 3 0 1 0 1 
output:
bcdbacdadb

input:
1
10
5 3 6 4 0 1 7 9 2 8 
1 2 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 2 1 
output:
ccdbcabcdd

input:
4
6
5 4 0 1 2 3 
1 2 3 2 1 0 3 0 1 0 1 
8
0 1 6 4 2 3 7 5 
1 2 1 0 1 0 1 0 1 0 3 0 3 0 1 
10
6 5 1 2 9 4 0 8 3 7 
1 0 1 4 1 0 1 4 1 0 1 0 1 0 1 0 1 2 1 
5
0 1 2 3 4 
1 2 3 4 3 2 1 0 1 
output:
bbbcba
aabcadad
cbbccbadcc
aaaab

input:
1
5
1 4 0 3 2 
1 0 3 0 1 2 1 0 1 
output:
caccb
*/
